<?php
/**
 * Tabulka dynamickeho pohladu
 * @author Tomas Srna
 * @package bakalarka
 */

class DynamicTable
{
	public $headers = array();
	public $writers = array();
	public $data = NULL;
	public $primaryKeys = array();
	
	public $buttons = array();
	
	public function __construct()
	{
		$this->buttons = array(
			new Button('pencil.png', L::selected()->edit, 
				"act('edit', false, %params%)"),
			new Button('delete.png', L::selected()->delete, 
				"act('delete', true, %params%)"),
		);
	}
	
	public function check($params, $by_possible)
	{
		$order_possible = array("asc", "desc", "");
		
		if( array_key_exists('page', $params) && !is_numeric($params['page']) ||
			array_key_exists('by', $params)   && !in_array($params['by'], $by_possible) ||
			array_key_exists('order', $params)   && !in_array($params['order'], $order_possible)
		)
			return false;
		
		return true;
	}
}
